#if !defined(TreeHeader)
#define TreeHeader

#include <string.h>

#include "node.h"
#include "switcher.h"

class Tree : public Node {
public:
  Tree (const char o[2]) :
    fixed (false) {
    ops[0] = o[0];
    ops[1] = o[1];
  }

  Tree (const char o[2], const pNode &l, const pNode &r) :
    fixed (false), left (l), right (r) {
    ops[0] = o[0];
    ops[1] = o[1];
  }

  static const NodeType ID = 12;

  NodeType type () const {
    return ID;
  }

  std::string dump (int);
  std::string display (int);

  Tree &tree () {
    return *this;
  }

  pNode replicate ();

  virtual bool doSwitch (Switcher &switcher) {
    return switcher.tree (*this);
  }

  std::string opString ();

  bool fixed;
  char ops[2];
  pNode left, right;

  int findOperatorIndex ();
  std::string padOperator (); // Appends space to operator, i.e. fancier
};

int tupleOperator ();

#define equalOp(o1,o2) ((o1)[0] == (o2)[0] && (o1)[1] == (o2)[1])

#endif
